// packageAPI/pages/userCryptoManager/userCryptoManager.js
var userCryptoManager = null
Page({
  /**
   * 页面的初始数据
   */
  data: {
    schema: [],
    formData: {
    },
    title: '',
    result: '',
    zh:'',
    apiType: '',
    remark: '',
    webUrl: '',
    apiName: '',
  },
  onLoad(options) {
    this.setData({
      apiType: options.zh,
      title: options.title,
      zh: options.zh,
      remark: options.remark,
      webUrl: options.webUrl
    })
    userCryptoManager = wx.getUserCryptoManager()
  },
  getLatestUserKey() {
    userCryptoManager.getLatestUserKey({
      complete:(res)=>{
        this.setData({
          result:res,
          apiName:'UserCryptoManager.getLatestUserKey'
        })
      }
    })
  },
  getRandomValues() {
    userCryptoManager.getRandomValues({
      length:10,
      complete:(res)=>{
        this.setData({
          result:wx.arrayBufferToBase64(res.randomValues),
          apiName:'UserCryptoManager.getRandomValues'
        })
      }
    })
  },
})